<?php
namespace  app\portal\controller;

use app\portal\model\TeacherModel;
use  cmf\controller\HomeBaseController;
use Dompdf\FrameDecorator\NullFrameDecorator;
use think\Db;
use think\Image;
use  think\Request;
use think\Session;

class TeacherController  extends HomeBaseController{

    public function  teacher(Request $request){

//    $id= Db::name('teacher')->getLastInsID();
//     var_dump($id);
        //根据user_id拿到teacher_id
        //dump($this->uid);

        Session::set('teacher_id',8);
       /* $tezcher_id = Db::name('teacher')->where("users_id",$this->uid)->field("id")->find();
        session('teacher_id',$tezcher_id['id']);*/
        //dump(Session::get("teacher_id"));
        //获取数据后，使页面中的为填写消失
        $t1="未填写";
        $t2="未填写";
        $t3="未填写";
        $t4="未填写";
        $t5="未填写";
        $t6="未填写";
        $t7="暂无";
        $t8="暂无";
        $xl="未填写";
        $fc="未填写";
        $test_id =Session::get("teacher_id");
        $flag = $request->param('flag');
        //teacher_id 后面的数字代表用户登陆后  需要获取的teacher_id
        if($flag=='1'){
            $t1="";
        }  $this->assign("t1",$t1);
        if(Db::name('teacher')->where('id',$test_id)->field('age')->find()){
            $t1="";
        } $this->assign("t1",$t1);
        if(Db::name('teacher_character')->where('teacher_id',$test_id)->find()){
            $t2="";
        } $this->assign("t2",$t2);
        if(Db::name('teacher_case')->where('teacher_id',$test_id)->find()){
            $t3="";
        } $this->assign("t3",$t3);
        if(Db::name('teacher_experience')->where('teacher_id',$test_id)->find()){
            $t4="";
        } $this->assign("t4",$t4);
        if(Db::name('teacher_graduate_school')->where('teacher_id',$test_id)->find()){
            $t5="";
        } $this->assign("t5",$t5);
        if(Db::name('teacher_course_manager')->where('teacher_id',$test_id)->find()){
            $t6="";
        } $this->assign("t6",$t6);
        if(Db::name('teacher_subscribe')->where('teacher_id',$test_id)->where('static',0)->whereOr('static',1)->whereOr('static',-1)->find()){
            $t7="";
        } $this->assign("t7",$t7);
        /* dump($t7);
         die;*/
        if(Db::name('teacher_liuyan')->where('teacher_id',$test_id)->where('static',0)->find()){
            $t8="";
        } $this->assign("t8",$t8);
        if(Db::name('teacher')->where('id',$test_id)->field('education')->find()){
            $xl="";
        } $this->assign("xl",$xl);
        if(Db::name('teacher_picture')->where('teacher_id',$test_id)->find()){
            $fc="";
        } $this->assign("fc",$fc);

        $tx = Db::name('teacher')
            ->where('id',$test_id)
            ->field('picture,name')
            ->find();
        $sub=  Db::name('teacher_course_manager')->where('teacher_id',$test_id)->find();
        $this->assign('data',$tx);
        $this->assign('sub',$sub);
        return $this->fetch(':teacher');

    }


    //****************头像设置*******************
    public function txset(){
        //获取提交的照片
        $file = request()->file('tx');
//        return json_encode($file);
        //从数据库拿到原图片路径
        $admin = Db::name('teacher')->where('id',Session::get("teacher_id"))->find();
        //删除本地原图片
        if(isset($admin['picture'])){
            @unlink(CMF_ROOT . 'public' .$admin['picture']);
        }else{

        }
        //存储新图片到本地
        $info = $file->move(CMF_ROOT . 'public' . DS . 'upload');
        if ($info) {
            $save_path = DS . date('Ymd') . DS;
            //插入新地址到数据库
            if(Db::name('teacher')->where('id', Session::get("teacher_id"))->update(['picture' =>'/upload'.$save_path . $info->getFilename()])){
                echo json_encode('\upload'.$save_path . $info->getFilename());
            }
            else{
                echo json_encode(0);
            }
        }
    }



//个人资料-------------------------------------开始
//****************页面展示*******************
    public function  teacher1()
    {
        //从数据库拿老师资料
        $grzl=Db::name('teacher')->where('id',Session::get("teacher_id"))->find();
        //若个人资料存在
        if($grzl['age']!=NULL){
            //dump($grzl).die;
            $this->assign('data', $grzl);
            return $this->fetch(':teacher1.1');
        }
        else{
            return $this->fetch(':teacher1');
        }

    }
//******************数据插入数据库*********************
    public function t1(Request $request)
    {
            $sql = Db::name('teacher')->where('id',Session::get("teacher_id"))->update(['name' => $_POST["name"], 'sex' => $_POST["sex"], 'age' => $_POST["age"],'school_age' => $_POST["school_age"],
                'city' => $_POST["city"],'qq' => $_POST["qq"], 'wechat' => $_POST["wechat"], 'tel' => $_POST["tel"]]);
            if ($sql) {
                $this->redirect('Teacher/teacher');
            }
        }
 //***************更新数据**********
    public function  t11(){
        $code = Db::name('teacher')
            ->where('id',Session::get("teacher_id"))
            ->update(['name' => input('name'),'sex'=>input('sex'),'qq'=>input('qq'),'wechat'=>input('wechat'),'tel'=>input('tel'),'age'=>input('age'),'city'=> $_POST["city"],'school_age' => $_POST["school_age"],]);
        $this->redirect('Teacher/teacher');
      /* if ($code) {
            $this->redirect('Teacher/teacher');
        } else {
            $this->error("添加失败");
        }*/
    }
//个人资料-------------------------------------结束



//个人风采-------------------------------------开始
    public function  fengcai()
    {
        //从数据库拿老师照片
        $pic = Db::name('teacher_picture')
            ->where('teacher_id',Session::get("teacher_id"))
            ->field('picture_path,id')
            ->select();
        //dump(isset($pic[0])).die;
        //若照片存在
        if(isset($pic[0])){
        }
        else{
            $pic="";
        }
        $this->assign('pic', $pic);
        return $this->fetch(':fengcai');
    }
    //***************图片上传*************
    public function up(){
        $file = request()->file('image2');
        $info = $file->move(CMF_ROOT . 'public' . DS . 'upload');
        if ($info) {
            $save_path = DS . date('Ymd') . DS;
            //字符串替换
            if(Db::name('teacher_picture')->insert(['picture_path' =>str_replace("\\","/", $save_path . $info->getFilename()),'teacher_id'=>Session::get("teacher_id")])){
                echo json_encode(1);
            }
            else{
                echo json_encode(0);
            }
        }
    }
    //*********删除图片*******
    public function photos_del()
    {

        $PicturePath=Db::name('teacher_picture')->where('id',input('f'))->find();
        //删除原图片
        @unlink(CMF_ROOT . 'public'  . DS . 'upload'.$PicturePath['picture_path']);
        $result = Db::name('teacher_picture')->where('id',input('f'))->delete();
        return json_encode($result);
       // return $result ? 1 : 0;
    }
//个人风采-------------------------------------结束



//教学特点-------------------------------------开始
    public function  teacher2(Request $request){  //页面展示
        //将获取的数据展示到页面上去-----开始
        $res = Db::name('teacher_character')->where('teacher_id',Session::get("teacher_id"))->find();//"teacher"  代表教学特点表qq_teacher_character
        if($res != null){
            $this->assign('tc2',$res);
            return $this->fetch('/teacher2.1');
        }
        else{
            return $this->fetch('/teacher2');
        }
        //将获取的数据展示到页面上去-----结束
        return $this->fetch('/teacher2');
    }
    public function  t2(){//向数据库插入数据
        $code  = Db::name('teacher_character')->insert(['tager'=>$_POST["gxbq"], 'charater'=>$_POST["tdjs"] ,'teacher_id'=>Session::get("teacher_id")]);
        if($_POST["gxbq"]=="" || $_POST["tdjs"]==""){
            $this->redirect('Teacher/teacher2');
        }
        else  if($code){
            $this->redirect('Teacher/teacher');
        }
        else{$this->error("添加失败");}
    }
    public  function teacher21(){//页面编辑

        $res = Db::name('teacher_character')->where('teacher_id',Session::get("teacher_id"))->find();
        $this->assign('tc2',$res);

        return $this->fetch('/teacher2.2');
    }
    public function  t21(){//向数据库更新数据
        $code  = Db::name('teacher_character')->where('teacher_id',Session::get("teacher_id"))->update(['tager'=>$_POST["gxbq"], 'charater'=>$_POST["tdjs"]  ]);
        if($_POST["gxbq"]=="" || $_POST["tdjs"]==""){
            $this->redirect('Teacher/teacher2');
        }
        else  if($code){
            $this->redirect('Teacher/teacher');
        }
        else{$this->error("添加失败");}
    }
//教学特点-------------------------------------结束



//成功案例-------------------------------------开始
    public function  teacher3(){ //如果是已登录过的用户就将让的信息展示到页面上   渲染模板

        $res = Db::name('teacher_case')->where('teacher_id',Session::get("teacher_id"))->select();//"teacher"  代表教学特点表qq_teacher_character
        if(isset($res[0])){
            $this->assign('tc3',$res);
            return $this->fetch('/teacher3.1');
        }
        else{
            return $this->fetch('/teacher3');
        }
        return $this->fetch('/teacher3');
    }
    public function  t3(){    //将用户填写的数据插入到数据库中
        //dump(Session::get("teacher_id")).die;
        $code  =    Db::name('teacher_case')->insert(['student_school'=>$_POST["studentschool"], 'case_introduction'=>$_POST["introduction"] ,'teacher_id'=>Session::get("teacher_id")]);
        if($_POST["studentschool"]=="" || $_POST["introduction"]==""){
            $this->redirect('Teacher/teacher3');
        }
        else  if($code){
            $this->redirect('Teacher/teacher',["flag"=>3]);
        }
        else{
            $this->error("添加失败");
        }
    }
    public function  t31(){   //点击新增跳入新增页面

        return $this->fetch('/teacher3');
    }
    public  function t32(Request $request){//页面编辑 并将原有数据展示到页面上
        $id = $request->param("id");
//    var_dump($id).die();
        $res = Db::name('teacher_case')->where('id', $id)->find();
        $this->assign('tc3',$res);
        return $this->fetch('/teacher3.2');
    }
    public function  t33(Request $request){//点击编辑进入此页面   向数据库更新数据
        $id = $request->param("id");
        dump($id).die;
//        dump($_POST["introduction"]).die;
        if($_POST["studentschool"]=="" || $_POST["introduction"]==""){
            $this->redirect('Teacher/teacher3');
        }
        else{
             Db::name('teacher_case')->where('id',$id)->update(['student_school'=>$_POST["studentschool"], 'case_introduction'=>$_POST["introduction"]  ]);
//            if(){
                $this->redirect('Teacher/teacher');
//            }
//            else{$this->error("添加失败");}
//
        }

    }
    public function  t34(Request $request){//点击删除按钮删除 数据库中的这一条数据
        $id = $request->param("id");
        $code = Db::name('teacher_case')->where('id',$id)->delete();
        if($code){
            // $this->success("删除成功",url('Teacher/teacher3.1'));
            $this->redirect('Teacher/teacher3.1');
        }
        else{
            $this->error("删除失败");
        }
    }
//成功案例-------------------------------------结束


//教学经历-------------------------------------开始
    public function  teacher4(){
        $res = Db::name('teacher_experience')
            ->where('teacher_id',Session::get("teacher_id"))
            ->select();//"teacher"  代表教学特点表qq_teacher_character
        if(isset($res[0])){
            $this->assign('tc4',$res);
            //dump($res).die;
            return $this->fetch('/teacher4.1');
        }
        else{
            return $this->fetch('/teacher4');
        }
        return $this->fetch('/teacher4');
    }
    public function  t4(){
        $code  =    Db::name('teacher_experience')
            ->insert(['experience_time'=>$_POST["start_date"]."~".$_POST['end_date'], 'details'=>$_POST["detail"] ,'title'=>$_POST["title"] ,'teacher_id'=>Session::get("teacher_id") ]);
//            dump($code).die;
        if( $_POST["start_date"]==""|| $_POST["end_date"]=="" || $_POST["detail"]==""|| $_POST["title"]==""){
            $this->redirect('Teacher/teacher4');
        }
        else  if($code){
            $this->redirect('Teacher/teacher4');
        }
        else{
            $this->error("添加失败");
        }
    }
    public  function teacher41(){//页面编辑
        $id=input('id');
        //dump($id).die;
        $res = Db::name('teacher_experience')
            ->where('id',$id)
            ->find();
        $timef=explode(' ',$res['experience_time']);
        $this->assign('time',$timef);
        $this->assign('tc4',$res);
        //dump($res).die;
        return $this->fetch('/teacher4.2');
    }
    public function  t41(){//向数据库更新数据
        $id=input('id');
        $time=Db::name('teacher_experience')->field('experience_time,details')
            ->where(['teacher_id'=>Session::get("teacher_id"),'id'=>$id])
            ->find();
        $timef=explode(' ',$time['experience_time']);
        if(input('start_date') && input('end_date')){

        }elseif(!input('start_date')){
            $_POST['start_date']=$timef[0];
        }elseif(!input('end_date')){
            $_POST['end_date']=$timef[1];
        }
        else{
            $_POST['start_date']=$timef[0];
            $_POST['end_date']=$timef[1];
        }
        if(input('detail')!=Null){
        }
        else{
            $_POST['detail']=$time['details'];
        }

        $code  = Db::name('teacher_experience')->where(['teacher_id'=>Session::get("teacher_id"),'id'=>$id])
            ->update(['experience_time'=>$_POST["start_date"].' '.$_POST["end_date"], 'details'=>$_POST["detail"], 'title'=>$_POST["title"]  ]);
        if($_POST["start_date"]==""|| $_POST["end_date"]=="" || $_POST["detail"]==""|| $_POST["title"]==""){
            $this->redirect('Teacher/teacher4');
        }
        else  if($code){
            $this->redirect('Teacher/teacher');
        }
        else{$this->error("添加失败");}
    }
    public function  add41(){
        $res = Db::name('teacher_experience')->where('id',input('id'))->find();
        $this->assign('tc4',$res);
        return $this->fetch('/teacher4.1');
    }
    //新增
    public function  add(){
        //$id=input('id');
        // dump($id).die;
        $res = Db::name('teacher_experience')
            ->where('teacher_id',Session::get("teacher_id"))
            ->select();
        // dump($res).die;
        if($res){
            return $this->fetch('/teacher4');
        }
        else{
            $this->error("新增失败");
        }

        // return redirect('Teacher/add41');
    }
    //删除
    public function delete(){
        $id=input('id');
        $res = Db::name('teacher_experience')
            ->where('id',$id)
            ->delete();
        if($res){
            return redirect('Teacher/teacher4');
        }
        else{
            $this->error("删除失败");
        }
    }
//教学经历-------------------------------------结束



//认证中心-------------------------------------开始
    public function  renzheng()
    {
        //从数据库拿老师照片
        $data = Db::name('teacher')
            ->where('id',Session::get("teacher_id"))
           ->find();
       // dump($data).die;
        //若照片存在
        if(isset($data['education'])){
            $this->assign('xueli', "");
        }
        else{
            $this->assign('xueli', "尚未提供认证资料");

        }
        if(isset($data['name'])){
            $this->assign('shiming', "");
        }
        else{
            $this->assign('shiming', "尚未提供认证资料");

        }
       if(isset($data['jszg'])&&$data['jszg']=="1"){
            $this->assign('teacher', "");
        }
        else{
            $this->assign('teacher', "尚未提供认证资料");

        }
        return $this->fetch(':renzheng');
    }
    function xueli(){

        return $this->fetch(":renzhengxueli");
    }

//认证中心-------------------------------------结束

//毕业院校-------------------------------------开始
    public function  teacher5(){
        $res = Db::name('teacher_graduate_school')
            ->where('teacher_id',Session::get("teacher_id"))
            ->select()->toArray();//"teacher"  代表教学特点表qq_teacher_character
         /*dump($res[0]).die;*/
        if(isset($res[0])){
            $this->assign('tc5',$res);
            return $this->fetch(":teacher5.1");
        }
        else{
            return $this->fetch('/teacher5');
        }
        return $this->fetch('/teacher5');
    }
    public function  t5(){//插入数据
        $code = Db::name('teacher_graduate_school')
            ->insert(['school'=>$_POST["schoolname"], 'department'=>$_POST["department"],'major'=>$_POST["major"]  ,'school_time'=>$_POST["start_date"]." ".$_POST['end_date'],'teacher_id'=>Session::get("teacher_id") ]);
        if($_POST["schoolname"]=="" || $_POST["department"]==""   || $_POST["major"]==""  ||  $_POST["start_date"]==""||  $_POST["end_date"]==""){
            $this->redirect('Teacher/teacher5');
        }
        else  if($code){
            $this->redirect('Teacher/teacher5');
        }
        else{
            $this->error("添加失败");
        }

    }
    public  function teacher51(){//页面编辑
        $id=input('id');
        $res = Db::name('teacher_graduate_school')
//            ->join('qq_teacher','qq_teacher_graduate_school.teacher_id=qq_teacher.id')
            ->where('id',$id)->find();
        //   dump($res).die;
        $timef=explode(' ',$res['school_time']);
        $this->assign('time',$timef);
        $this->assign('tc5',$res);
        return $this->fetch('/teacher5.2');
    }
    public function  t51(){//向数据库更新数据
        $time  = Db::name('teacher_graduate_school')->field("school_time")->where('teacher_id',Session::get("teacher_id"))->find();
        $timef=explode(' ',$time['school_time']);
        // print_r($timef).die;
        //dump($timef);
        if(input('start_date')&&input('end_date')){

        }else{
            if(!input('start_date')){
                $_POST["start_date"]=$timef[0];
            }
            if(!input('end_date')){
                $_POST["end_date"]=$timef[1];
            }
        }
        //dump($_POST["start_date"].$_POST["end_date"]).die;
        $code  = Db::name('teacher_graduate_school')->where('teacher_id',Session::get("teacher_id"))->update(['school'=>$_POST["schoolname"], 'department'=>$_POST["department"]  , 'major'=>$_POST["major"] , 'school_time'=>$_POST["start_date"]." ".$_POST['end_date']]);
        if($_POST["schoolname"]=="" || $_POST["department"]==""   || $_POST["major"]==""  ||  $_POST["start_date"]==""||  $_POST["end_date"]==""){
            $this->redirect('Teacher/teacher5');
        }

            $this->redirect('Teacher/teacher');
    }
    //新增
    public function  add5(){
        //$id=input('id');
        // dump($id).die;
        $res = Db::name('teacher_graduate_school')
            ->where('teacher_id',Session::get("teacher_id"))
            ->select();
        // dump($res).die;
        return $this->fetch('/teacher5');
    }
    //删除
    public function delete5(){
        $id=input('id');
//     dump($id).die;
        $res = Db::name('teacher_graduate_school')
            ->where('id',$id)
            ->delete();
        return redirect('Teacher/teacher5');
    }

//毕业院校-------------------------------------结束



//课程管理-------------------------------------开始
    public function  teacher6(){
        $res = Db::name('teacher_course_manager')->where('teacher_id',Session::get("teacher_id"))->select();//"teacher"  代表教学特点表qq_teacher_character
        if(isset($res[0])){
            $this->assign('tc6',$res);
            return $this->fetch('/teacher6.1');
        }
        else{
            return $this->fetch('/teacher6');
        }
        return $this->fetch('/teacher6');
    }
    public function  t6(){
        $code  =    Db::name('teacher_course_manager')->insert(['subject'=>$_POST["subject"], 'grade'=>$_POST["grade"] ,'price'=>$_POST["price"],'time'=>$_POST["time"] ,'addr'=>$_POST["addr"] ,'detail_addr'=>$_POST["content"],  'teacher_id'=>Session::get("teacher_id") ]);
        if($_POST["subject"]=="" || $_POST["grade"]==""  || $_POST["price"]==""||$_POST["time"]=="" || $_POST["addr"]==""  || $_POST["price"]==""){
            $this->redirect('Teacher/teacher6');
        }
        else  if($code){
            $this->redirect('Teacher/teacher');
        }
        else{
            $this->error("添加失败");
        }
    }
    public function  t61(){   //点击新增跳入新增页面

        return $this->fetch('/teacher6');
    }
    public  function t62(Request $request){//页面编辑 并将原有数据展示到页面上
        $id = $request->param("id");
        //    var_dump($id).die();
        $res = Db::name('teacher_course_manager')->where('id', $id)->find();
        $this->assign('tc6',$res);
        return $this->fetch('/teacher6.2');
    }
    public function  t63(Request $request){//点击编辑进入此页面   向数据库更新数据
        $id = $request->param("id");

        if(input('content')==""){
            $add = Db::name('teacher_course_manager')->where('id', $id)->field('detail_addr')->find();
            $_POST["content"]=$add["detail_addr"];
        }
       // dump($_POST["content"]).die;
        $code  = Db::name('teacher_course_manager')->where('id',$id)->update(['subject'=>$_POST["subject"], 'grade'=>$_POST["grade"] , 'price'=>$_POST["price"],'time'=>$_POST["time"] ,'addr'=>$_POST["addr"],'detail_addr'=>$_POST["content"],]);
        if($_POST["subject"]=="" || $_POST["grade"]==""  || $_POST["price"]==""||$_POST["time"]=="" || $_POST["addr"]==""  || $_POST["price"]==""){
            $this->redirect('Teacher/teacher6');
        }

            $this->redirect('Teacher/teacher');

    }
    public function  t64(Request $request){//点击删除按钮删除 数据库中的这一条数据
        $id = $request->param("id");
        Db::name('teacher_course_manager')->where('id',$id)->delete();
        // $this->success("删除成功",url('Teacher/teacher3.1'));
        $this->redirect('Teacher/teacher6.1');

    }
//课程管理-------------------------------------结束
    /*预约管理*/
    public function  subscribe_detail(){
        $res_dai = Db::name('teacher_subscribe')->where('teacher_id',Session::get("teacher_id"))->where('static',0)->select();//"teacher"  代表教学特点表qq_teacher_character
        $res_accept = Db::name('teacher_subscribe')->where('teacher_id',Session::get("teacher_id"))->where('static',1)->whereOr('static',-1)->select();
        $res = Db::name('teacher_subscribe')->where('teacher_id',Session::get("teacher_id"))->select();
        if($res != null){
            //应从用户表拿到用户名称
            /*dump($res);
                        die;*/
            $this->assign('res_dai',$res_dai);
            $this->assign('res_accept',$res_accept);
            $this->assign('res',$res);
            return $this->fetch('/subscribe_detail');
        }
        else{

        }
    }
    public function  subscribe_del(){
        if(input('rejecd_id')){
            $code = Db::name('teacher_subscribe')
                ->where('id',input('rejecd_id'))
                ->update(['static' => -1]);
            if($code){
                return 1;
            }
        }
        elseif(input('accept_id')){
            $code = Db::name('teacher_subscribe')
                ->where('id',input('accept_id'))
                ->update(['static' => 1]);
            if($code){
                return 1;
            }
        } elseif(input('del_id')){
            $code = Db::name('teacher_subscribe')
                ->where('id',input('del_id'))
                ->update(['static' => -2]);
            if($code){
                return 1;
            }
        }


    }
    public function subscribe_content(){

        if(input('id')){
            $id = input('id');
            $content_data = Db::name('teacher_subscribe')->where('id',$id)->find();
            /*dump($content_data);
            die;*/
            $this->assign('content_data',$content_data);
            return $this->fetch(':subscribe_content');
        }
        else{

        }
    }
    /*预约管理*/
    /*留言管理*/
    public function  liuyan_detail(){
       /* $res_dai = Db::name('teacher_liuyan')->where('teacher_id',Session::get("teacher_id"))->where('static',0)->select();//"teacher"  代表教学特点表qq_teacher_character
        $res_accept = Db::name('teacher_liuyan')->where('teacher_id',Session::get("teacher_id"))->where('static',1)->select();*/
        $res = Db::name('teacher_liuyan')->where('teacher_id',Session::get("teacher_id"))->where('static',1)->whereOr('static',0)->order('comit_time',"desc")->select();
        if($res != null){
            //应从用户表拿到用户名称
            $this->assign('res',$res);
         /*   $this->assign('res_accept',$res_accept);
            $this->assign('res_dai',$res_dai);*/
            return $this->fetch(':liuyan_detail');
        }

    }
    public function liuyan_content(){
        $res = Db::name('teacher_liuyan')->where('id',input('id'))->field('content')->find();

        if($res != null){
            Db::name('teacher_liuyan')
                ->where('id',input('id'))
                ->update(['static' => 1]);
            //应从用户表拿到用户名称
            $this->assign('res',$res['content']);
            /*   $this->assign('res_accept',$res_accept);
               $this->assign('res_dai',$res_dai);*/
            return $this->fetch(':liuyan_content');
        }
    }
    public function  liuyan_del(){

        if(input('accept_id')){
            $code = Db::name('teacher_liuyan')
                ->where('id',input('accept_id'))
                ->update(['static' => 1]);
            if($code){
                return 1;
            }
        } elseif(input('del_id')){
            $code = Db::name('teacher_liuyan')
                ->where('id',input('del_id'))
                ->update(['static' => -1]);
            if($code){
                return 1;
            }
        }


    }
    /*留言管理*/
}